<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <title>编辑商品</title>
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap/dist/css/bootstrap.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/animate.css/animate.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/font-awesome/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/simple-line-icons/css/simple-line-icons.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-editable/css/bootstrap-editable.min.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/font.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/app/css/app.css" type="text/css" />
    <link rel="stylesheet" href="__ADMIN_STATICS__/bootstrap-touchspin/jquery.bootstrap-touchspin.min.css" type="text/css" />
    <webuploadercss/>
</head>
<body>
<script src="__ADMIN_STATICS__/jquery/jquery.min.js"></script>
<script src="__ADMIN_STATICS__/bootstrap/dist/js/bootstrap.js"></script>
<div class="wrapper-md">
   <div class="panel panel-default">
    <div class="panel-heading">
        <a href="{:U('Admin/Index/welcome')}"><i class="fa fa-home"></i>&nbsp;首页&nbsp;</a>&gt;&nbsp;&nbsp;<a href="{:U('Admin/Goods/index')}">产品列表</a>&nbsp;&gt;&nbsp;&nbsp;修改
    </div>
    <div class="table-responsive">
        <form class="form-horizontal" action="{:U('Admin/Goods/edit')}" method="post"> 
            <!-- Nav tabs -->
            <ul class="nav nav-tabs text-center" role="tablist">
                <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">基础信息</a></li>
                <li role="presentation"><a href="#content" aria-controls="content" role="tab" data-toggle="tab" id="content_config">内容</a></li>
                <li role="presentation"><a href="#album" aria-controls="album" role="tab" data-toggle="tab" id="album_config">产品材料</a></li>
            </ul>
            <!-- Tab panes -->
            <div class="tab-content">
                <div role="tabpanel" class="tab-pane active" id="home">
                    <input type="hidden" name="id" value="{$data['id']}" />
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">产品名称</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title" value="{$data['title']}" >
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">产品代码</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sn" value="{$data['sn']}" >
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label">分类</label>
                        <div class="col-sm-6">
                            <select name="cateid" class="form-control" >
                                <volist id="category" name="allCategory">
                                    <option value="{$category.id}" <if condition="$category['id'] eq $data['cateid']">selected</if>>{$category['_name']}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">风险评级</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="fengxian"  placeholder="1-5" value="{$data['fengxian']}">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">规模</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="guimo"  placeholder="300万" value="{$data['guimo']}">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">业绩比较基准</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="jizhun"  placeholder="6% - 7%" value="{$data['jizhun']}">
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">类固收</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="rank1"  placeholder="8.5%@100万(含)~300万" value="{$data['rank1']}">
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">类固收</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="rank2"  placeholder="8.5%@100万(含)~300万" value="{$data['rank2']}">
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">产品期限</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="qixian" value="{$data['qixian']}">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">募集日期-起始</label>
                        <div class="col-sm-6">
                            <input type="text" value="{$data['start_time']}" class="form-control" name="start_time">
                        </div>
                    </div>
					<div class="line line-dashed b-b line-lg pull-in"></div>
					<div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">募集日期-结束</label>
                        <div class="col-sm-6">
                            <input type="text" value="{$data['end_time']}" class="form-control" name="end_time">
                        </div>
                    </div>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label" for="input-id-1">排序</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sort" value="{$data['sort']}" >
                        </div>
                    </div>
                    <div id="expand">

                    </div>
                </div>
                <div role="tabpanel" class="tab-pane" id="content">
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-1 control-label"></label>
                        <div class="col-sm-10">
                            <ueditor name="content" content="{$data['content']}"/>
                        </div>
                    </div>  
                </div>
                <div role="tabpanel" class="tab-pane" id="album">
                    <if condition="$data['album'] neq null">
                        <div class="line line-dashed b-b line-lg pull-in"></div>
                        <div class="form-group m-b-none m-l-none m-r-none">
                            <label class="col-sm-2 control-label">已上传附件</label>
                            <div class="col-sm-8">
                                <volist name="data['album']" id="v">
                                    <div class="col-sm-6 v-m m-b-xs album_{$v['id']}">
                                        <div class="col-sm-9">
                                             {$v['name']}
                                            <button type="button" onclick="javascript:if(confirm('确定删除附件？'))delete_album(this)" data-id="{$v['id']}" class="btn btn-danger">删除</button>
                                        </div>
                                    </div>
                                </volist>
                            </div>
                        </div>
                    </if>
                    <div class="line line-dashed b-b line-lg pull-in"></div>
                    <div class="form-group m-b-none m-l-none m-r-none">
                        <label class="col-sm-2 control-label">上传附件</label>
                        <div class="col-sm-6 v-m">
                             <!-- 上传组件容器 开始-->
                            <div id="album_upload" class="xb-uploader">
                                <div class="queueList">
                                    <div class="placeholder">
                                        <div class="filePicker"></div>
                                        <p>选择附件</p>
                                    </div>
                                </div>
                                <div class="statusBar" style="display:none;">
                                    <div class="progress">
                                        <span class="text">0%</span>
                                        <span class="percentage"></span>
                                    </div>
                                    <div class="info"></div>
                                    <div class="btns">
                                        <div class="uploadBtn">开始上传</div>
                                    </div>
                                </div>
                                <div class="album_list" style="display: none;">
                                </div>
                            </div>
                            <!-- 上传组件容器 结束-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="line line-dashed b-b line-lg pull-in"></div>
            <div class="col-sm-4 col-sm-offset-2 m-b">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
        </form>
    </div>
  </div>
</div>
<script src="__ADMIN_STATICS__/webuploader-0.1.5/webuploader.js"></script>
<script src="__ADMIN_STATICS__/webuploader-0.1.5/uploaderSf.js"></script>  
<script src="__ADMIN_STATICS__/bootstrap-touchspin/jquery.bootstrap-touchspin.min.js"></script>  
<script type="text/javascript">

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
    // 获取已激活选项卡的名称
    var activeTab = $(e.target).attr('aria-controls');
    var multiple = false;
    var type = 'goods';
    if (activeTab == "album") {
        multiple = true;
    }
    if (activeTab == 'attachment') {
        type = 'file';
    }
    // 初始化上传组件
    upload_init(activeTab,multiple,type);
});

function upload_init(activeTab,multiple,type){
     $('#'+activeTab+'_upload').sfUpload({
        url:"/index.php?m=Admin&c=Article&a=upload&type="+type,
        picker:activeTab+'_upload',
        multiple:multiple,
        success:function( data ) {
            if(activeTab == 'album'){
                var str = '<input name="album_path[]" type="hidden" value="'+data.path;
                str += '"/><input name="album_name[]" type="hidden" value="'+data.original;
                str += '"/>';
                $('.album_list').append(str);
            }else{
                $("input[name='"+activeTab+"_path']").val(data.path);
                $("input[name='"+activeTab+"_name']").val(data.original);
            }
        },
        error:function( err ) {
            console.info( err );    
        }
    });
}

function delete_album(obj){
    var id = $(obj).attr('data-id');
    $.ajax({
        url : "{:U('Admin/Goods/delete_album')}",
        type : "post",
        dataType : "json",
        data : {id:id},
        success : function(data){
            if(data.code){
                $('.album_'+id).remove();
            }else{
                alert(data.msg);
            }
        }
    });
}
function preview(obj){
    var path = $(obj).attr('data-url');
    $('#preview img').attr('src', path);
    $('#preview').modal('show');
}
</script>
</body>
</html>
